/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.report.mapper.statistics;

import com.koron.report.bean.StatisticsBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * 随手拍次数统计，指标库编码为0109
 */
public interface FreeSnapNumberStatisticsMapper {

    @Select("<script>" +
            "select count(*) from free_snap" +
            " where (submit_time between #{startTime} and #{endTime}) " +
            "<if test='null!=codeList'>" +
            " and grid_code in" +
            "<foreach collection='codeList' item='code' open='(' close=')' separator=','>#{code}</foreach>" +
            "</if>"+
            "</script>")
    Integer countFreeSnapNumberByDeptOrGroup(@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("codeList")  List<String> codeList);

    @Select("<script>" +
            "select corp_code as code, count(*) as value from free_snap" +
            " where (submit_time between #{startTime} and #{endTime})" +
            " group by corp_code" +
            "</script>")
    List<StatisticsBean> countFreeSnapNumberByCorp(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    @Select("<script>" +
            "select count(*) from free_snap" +
            " where (submit_time between #{startTime} and #{endTime}) " +
            "<if test='null!=codeList'>" +
            " and corp_code in" +
            "<foreach collection='codeList' item='code' open='(' close=')' separator=','>#{code}</foreach>" +
            "</if>"+
            "</script>")
    Integer countFreeSnapNumberByDistrict(@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("codeList")  List<String> codeList);
}
